package com.zbkj.crmeb.merchant.admin.controller;

import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.store.response.StoreSaleAnalysisResponse;
import com.zbkj.crmeb.store.service.StoreSaleAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Api(tags = "销售分析")
@RestController
@RequestMapping("/api/admin/mer/sale/analysis")
public class StoreSaleAnalysisController extends AdminBaseController{

    @Autowired
    StoreSaleAnalysisService storeSaleAnalysisService;

    /**
     * 功能描述: 查询商品概况信息
     * @Param: [request]
     * @Return: Map
     * @Author: duyb
     * @Date: 2022/10/13
     */
    @GetMapping("/survey")
    @ApiOperation("查询商品概况信息")
    public CommonResult<Map> getSurveyInfo(HttpServletRequest request){
        return CommonResult.success(storeSaleAnalysisService.getSurveyInfo(getMerId(request)));
    }

    /**
     * 功能描述: 查询商品转化信息
     * @Param: [request]
     * @Return: Map
     * @Author: duyb
     * @Date: 2022/10/13
     */
    @GetMapping("/conversion")
    @ApiOperation("查询商品转化信息")
    public CommonResult<Map> getConversionInfo(HttpServletRequest request){
        return CommonResult.success(storeSaleAnalysisService.getConversionInfo(getMerId(request)));
    }

    /**
     * 功能描述: 查询商品滞销信息
     * @Param: [request]
     * @Return: Map
     * @Author: duyb
     * @Date: 2022/10/13
     */
    @GetMapping("/unsalable")
    @ApiOperation("查询商品滞销信息")
    public CommonResult<Map> getUnsalableInfo(HttpServletRequest request){
        return CommonResult.success(storeSaleAnalysisService.getUnsalableInfo(getMerId(request)));
    }

    /**
     * 功能描述: 查询商品销售明细
     * @Param: [request，pageParamRequest]
     * @Return: CommonPage<StoreSaleAnalysisResponse>
     * @Author: duyb
     * @Date: 2022/10/14
     */
    @GetMapping("/product/detail")
    @ApiOperation("查询商品销售明细")
    public CommonResult<CommonPage<StoreSaleAnalysisResponse>> getProductDetail(HttpServletRequest request, @ModelAttribute PageParamRequest pageParamRequest){
        CommonPage<StoreSaleAnalysisResponse> saleAnalysisCommonPage = CommonPage.restPage(storeSaleAnalysisService.getProductDetail(getMerId(request), pageParamRequest));
        return CommonResult.success(saleAnalysisCommonPage);
    }
}
